import {http} from "../../utils/http";
// console.log(http)
// let page=0;
Page({
  data:{
    list:[],    //医院列表
    page:1,     //第几页
  },
  onPullDownRefresh(){
    // console.log("下拉刷新")
    setTimeout(() => {
      wx.stopPullDownRefresh({
        success: (res) => {
          console.log(res)
        },
      })
    }, 1000);
  },
  //页面加载，请求第1页数据
  onLoad(){
   this.getList()
  },
  //页面触底，请求page+1的数据
  onReachBottom(){
    //1.每次触底，页面page+1
    this.data.page+=1;
    this.getList()
  },
  //发送网络请求
  async getList(){
    //2.发送网络请求，携带参数page
    var result =await http({url:"/87-60",data:{cityName:"郑州",page:this.data.page}})
    var list =result.data.showapi_res_body.hospitalList;
    this.setData({
      list:this.data.list.concat(list), //3.新一页的数据，和上一页的数据进行拼接
    })

  },
  //跳转到详情页
  toDetail(e){
    var id=e.currentTarget.id;    //医院id
    wx.navigateTo({
      url: '/pages/detail/detail?id='+id,
    })
  }
})